"""列表"""
# type_list=["asd",231,"dsaf"]
# print(type_list)
# print(type(type_list))

# type_list=[[1,2,3],[1,2,3]]
# print(type_list)
# print(type(type_list))

"""下标索引"""
# type_list=[["hsf"],["gafhd"],["dghj"]]
# print(type_list[0])
# print(type_list[-2])

# t_list=[[1,2],[3,4]]
# print(t_list[1][0])
# print(t_list[-2][-1])

"""列表的方法"""
# 查找元素下标
# list_d=[123,456,789]
# print(list_d.index(123))
# 修改指定下标的元素的值
# list_d=[1,2,3,4]
# list_d[list_d.index(2)]=0
# print(list_d)
#
# list_d=[1,2,3,4]
# a=int(input("in"))
# list_d[list_d.index(a)]=0
# print(list_d)
# 插入元素
# list1=[1,2,3]
# a=int(input("num"))
# b=input("str")
# list1.insert(list1.index(a),b)
# print(list1)
#追加元素
# list1=[1,2,3]
# list1.append(4)
# print(list1)
# list1.extend([5,6,7])
# print(list1)
# 删除元素(指定下标)
# del list1[3]
# print(list1)
# a=list1.pop(0)
# print(list1)
# print(a)
# 删除元素（指定元素）
# list1.remove(3)
# print(list1)
# 清空列表
# list1.clear()
# print(list1)
# 统计数量
# list1[1]=3
# a=list1.count(3)
# print(list1)
# print(a)
# 统计列表的元素数量
# a=len(list1)
# print(a)

"""列表的遍历"""
# def f_01():
#     index=0
#     global list_01
#     list_01=[3,1,2,5,1,8,645]
#
#     while index<len(list_01):
#         print(list_01[index])
#         index+=1
# def f_02():
#     for x in list_01:
#         print(x)
#
# f_01()
# f_02()

"""元组的定义"""
# t1=(1,"dsa",True)
# print(type(t1))
# print(t1)
#
# t2=(1,)
# print(t2)
# print(type(t2))

"""元组的嵌套"""
# t1=((1,2,3),(4,5,6))
# print(t1)
# print(type(t1))
#
# print(t1[1][-1])

"""元组的方法"""
# t1=(1,2,1,2,31,"dsa",3,13)
# a=t1.index("dsa")
# print(a)
# b=t1.count(1)
# print(b)
# c=len(t1)
# print(c)

"""遍历元组"""
# t1=(1,2,3,4,5)
# def while_tuple():
#     index=0
#     while index<len(t1):
#         print(t1[index])
#         index+=1
# def for_tuple():
#     for x in t1:
#         print(x)
# while_tuple()
# for_tuple()
"""字符串下标索引"""
# str="dasdghsdfaz"
# print(str[2])
"""
查找特定字符串的下标
"""
# str="dasdghsdfaz"
# print(str.index("dgh"))
"""字符串的替换"""
# str="wellcome my load"
# str1=str.replace("wellcome","you are")
# print(str1)
# print(str)
"""序列的切片"""
# 对列表切片
# list1=[1,2,3,4,5,6,7,8,9,1]
# str=list1[4:6:1]
# print(str)
# str1=list1[::1]
# print(str1)
# str2=list1[-1:-3:-1]
# print(str2)
# str3=list1[1:7:3]
# print(str3)
# # 对元组切片
# tuple=(1,2,3,4,5,6,7,8,9,1)
# tup1=tuple[::-2]
# print(tup1)

"""集合"""
# set01={"dafa","d",1,1,324,562,1,1,13,1231}
# print(set01)
# print(type(set01))
# 添加
# set01={1,2,3,4,5,67,41,3,5}
# print(set01)
# set01.add(6)
# set01.add(1)
# print(set01)
# # 移除
# set01.remove(67)
# print(set01)
# # 随机取出
# a=set01.pop()
# print(a)
# # 清空集合
# set01.clear()
# print(set01)
"""差集"""
# set01={1,2,3}
# set02={2,3,4}
# a=set01.difference(set02)
# print(a)
# # 消除差集
# set01.difference_update(set02)
# print(set01)
# print(set02)
# # 合并集合
# set03=set01.union(set02)
# print(set03)
# print(set01)
# print(set02)
# # 计数
# set04={1,1,1,1,1,1,1,1,1,1,11,1}
# num=len(set04)
# print(num)
# # 遍历
# for x in set03:
#     print(x)
"""字典"""
# 定义
# dict1={"a":1,"b":2}
# dict2={}
# dict3=dict()
# print(dict1)
# print(dict2)
# print(dict3)
# 查找字典
# print(dict1["b"])
# 嵌套字典
# dict1={"wang":{"语文":99,"数学":100},"diyaboluo":{"语文":90,"数学":76}}
# print(dict1["wang"]["语文"])
# print(dict1["diyaboluo"]["数学"])

"""字典的方法"""
# 新增和更新
dict1={"a":1,"b":2,"c":3}
dict1["a"]=4
print(dict1)
dict1["d"]=5
print(dict1)
# 删除元素
grade=dict1.pop("d")
print(grade)
print(dict1)
#清空字典
# dict1.clear()
# print(dict1)
# 获取全部的key值
a=dict1.keys()
print(a)
# 遍历
# for key in dict1.keys():
#     print(f"{key}={dict1[key]}")
# for key in dict1:
#     print(key)
# 计数
# num=len(dict1)
# print(num)